package gdl.test;

import gdl.test.bean.User;
import gdl.test.dao.IUserDao;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.List;

import javax.annotation.Resource;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.transaction.annotation.Transactional;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("/Spring.xml")
@Transactional
@TransactionConfiguration(defaultRollback=false,transactionManager="txManager")
public class test {
	@Autowired
	private IUserDao iUserDao;
	
	@Test
	public void testADD() {
		//增
		/*User u=new User(8,"wangwu","1234","ww");
		iUserDao.add(u);*/
		//删
		/*User u=new User();
		u.setId(8);
		iUserDao.delete(u);*/
		//改
//		iUserDao.update(new User(8,"Mingxuan","123444","gdl"));
		//简单查询
//		System.out.println(iUserDao.findById(8).toString());
		
		//测试复杂查询
		
		List<User> list=iUserDao.findAll();
		//System.out.println(iUserDao.findAll());
		for(Object u:list){
			System.out.println(u.toString());
		}
		System.out.println(iUserDao.findusername());
	}

}
